﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PrimeNumbers
{
    class Program
    {
        static void Main(string[] args)
        {

            Console.Write("请输入下限：");
            int lowerLimit = int.Parse(Console.ReadLine());

            Console.Write("请输入上限：");
            int upperLimit = int.Parse(Console.ReadLine());


            List<int> primes = GetPrimesInRange(lowerLimit, upperLimit);

            int count = 0;
            foreach (var prime in primes)
            {
                Console.Write(prime + "\t");
                count++;
                if (count == 10)
                {
                    Console.WriteLine(); 
                    count = 0;
                }
            }

            if (count > 0)
            {
                Console.WriteLine();
            }
        }

        static bool IsPrime(int number)
        {
            if (number <= 1) return false;
            for (int i = 2; i <= Math.Sqrt(number); i++)
            {
                if (number % i == 0)
                    return false;
            }
            return true;
        }

        static List<int> GetPrimesInRange(int lower, int upper)
        {
            List<int> primes = new List<int>();
            for (int i = lower; i <= upper; i++)
            {
                if (IsPrime(i))
                {
                    primes.Add(i);
                }
            }
            return primes;
        }
    }
}
